package cn.dida.core;

import cn.dida.model.Sysres;
import cn.dida.model.UserSession;

import javax.servlet.http.HttpServletRequest;
/**
 * 线程变量容器
 * @author weiwei
 *
 */
@Deprecated
public class ThreadLocalContainer {
    // 登录session
    private static ThreadLocal<UserSession> userSession = new ThreadLocal<UserSession>();
    // 请求对象
    private static ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>();
    // 用于标识线程的唯一的标识符
    private static ThreadLocal<String> subjectId = new ThreadLocal<String>();
    // current res node
    private static ThreadLocal<Sysres> currentResNode = new ThreadLocal<>();


    public static void setUserSession(UserSession session) {
        userSession.set(session);
    }

    public static UserSession getUserSession() {
        return (UserSession) userSession.get();
    }

    public static HttpServletRequest getRequest() {
        return request.get();
    }

    public static void setRequest(HttpServletRequest request) {
        ThreadLocalContainer.request.set(request);
    }

    public static String getSubjectId() {
        return subjectId.get();
    }

    public static void setSubjectId(String subjectId) {
        ThreadLocalContainer.subjectId.set(subjectId);
    }


    public static Sysres getCurrentResNode() {
        return currentResNode.get();
    }

    public static void setCurrentResNode(Sysres subjectId) {
        ThreadLocalContainer.currentResNode.set(subjectId);
    }

}
